using System;
using System.Collections.Generic;
using System.Text;

namespace TmxUtil
{
    public class FillXXCulture
    {
        public static void Run(Solution solution)
        {
            foreach(Project p in solution.Projects)
            {
                ResXItemCollection ic = new ResXItemCollection(p.ResXList);
                ResXBrowser browser = new ResXBrowser(ic);
                string[] keys = browser.GlobalKeys;
                foreach(string gk in keys)
                {
                    ResXItem source = browser.GetLocalization(gk, String.Empty);
                    if (source != null)
                    {
                        string newValue =
                            string.Format(
                                "Fake Value of {2} at {1} :: {0} project",
                                source.ResX.Key,
                                p.File,
                                source.Key);

                        ic[p, source.ResX.Key, "xx", source.Key] = newValue;
                        if (ic[p, source.ResX.Key, "xx", source.Key] != newValue)
                            throw new InvalidOperationException("Data lost");
                    }
                }
            }
        }
    }
}
